2 Problem: 924 - Spreading the news (UVa Online Judge)
17 for (int i
=0; i
<E
; ++i
){
32 if (g
[u
].size() == 0){
35 int max_boom
= 0, first_day
= 0, booms
[E
];
37 memset(booms
, 0, sizeof booms
);
38 memset(visited
, false, sizeof visited
);
39 queue
<pair
<int, int> > q
;
40 q
.push(make_pair(u
, 0));
42 int person
= q
.front().first
;
43 int today
= q
.front().second
;
46 if (visited
[person
]) continue;
48 visited
[person
] = true;
50 if (booms
[today
] > max_boom
){
51 max_boom
= booms
[today
];
55 vector
<int> &friends
= g
[person
];
56 for (int i
=0; i
<friends
.size(); ++i
){
57 if (!visited
[friends
[i
]]){
58 q
.push(make_pair(friends
[i
], today
+ 1));
62 printf("%d %d\n", max_boom
, first_day
);